***** H2 - Parents hypothesis - by country

* Produce Figure 1 in Appendix O - Effect of having children aged between 18 and 34 years old 
* in the household on parents' level of satisfaction with the economy or government's performance 

		
	* Economy
		
		clear all
	
		cd "${data}"	
		
		use data_ess.dta, clear
		label drop dummy1834
		
		**** One country at a time 

		tempname economy_country
		
		postfile `economy_country' sample b_dummy1834 se_dummy1834  using economy_country.dta, replace
		
		foreach cntry of numlist 1(1)32 {  		
			local t : label cntry `cntry'
			noisily reg stfeco b0.dummy1834 agea income b0.unemployed education unemployment_rate i.essround [pw=pspwght] if country==`cntry' & agea>34, robust
			post `economy_country' (`cntry') (`=_b[1.dummy1834]') (`=_se[1.dummy1834]')
			}
			
		postclose `economy_country'
		
	use "economy_country.dta", clear
		sort b_dummy1834
		gen order= _n
		sort sample
		
		label define countrylabel 23 "AT" 17 "BE" 32 "BG" 18 "CH" 1 "CY" 3 "CZ" ///
		9 "DE" 25 "DK" 14 "EE" 22 "ES" 19 "FI" 28 "FR" 16 "GB" 26 "GR" 30 "HR" ///
		4 "HU" 8 "IE" 27 "IL" 20 "IS" 21 "IT" 10 "LT" 6 "LU" 15 "NL" 24 "NO" ///
		29 "PL" 31 "PT" 13 "RU" 11 "SE" 2 "SI" 5 "SK" 12 "TR" 7 "UA"
		

		label values order countrylabel
	
		gen lower=b_dummy1834-(1.96*se_dummy1834)
		gen upper=b_dummy1834+(1.96*se_dummy1834)

		graph set window fontface "Arial Narrow"
		
		tw rspike lower upper order, vert || scatter  b_dummy1834 order ,  msymbol(o)  msize(small) ///
		xlabel(1(1)32, valuelabel labsize(vsmall) angle(0)) ytitle("")  ///
		ylabel(-0.7(0.1).5, labsize(small) angle(0)) yscale(r(-0.7(0.1).5)) ///
		xtitle("Estimated effect of cohabitation with only young adults") ///
		legend(off) yline(0) xsc(reverse) xsize(6) ysize(4) title("Economy") aspectratio(0.4)  ///
		graphregion(margin(vsmall))  scheme(lean1) saving(${figures}/Figure_country_economy.gph, replace)
		
		
	* Government 
		
		clear 
			
		cd "${data}"	
		
		use data_ess.dta, clear
		label drop dummy1834
		
		**** One country at a time 
		
		tempname government_country
		
		postfile `government_country' sample b_dummy1834 se_dummy1834 using government_country.dta, replace
		
		foreach cntry of numlist 1(1)32 {  		
			local t : label cntry `cntry'
			noisily reg stfgov b0.dummy1834 agea income b0.unemployed education unemployment_rate i.essround [pw=pspwght] if country==`cntry' & agea>34, robust
			post `government_country' (`cntry') (`=_b[1.dummy1834]') (`=_se[1.dummy1834]')
			}
			
		postclose `government_country'
		
	use "government_country.dta", clear
		sort b_dummy1834
		gen order= _n
		sort sample
		
		label define countrylabel 12 "AT" 18 "BE" 31 "BG" 26 "CH" 32 "CY" 5 "CZ" ///
		 20 "DE" 9 "DK" 8 "EE" 24 "ES" 23 "FI" 29 "FR" 11 "GB" 27 "GR" 2 "HR" ///
		 4 "HU" 3 "IE" 28 "IL" 25 "IS" 13 "IT" 10 "LT" 30 "LU" 22 "NL" 14 "NO" ///
		 21 "PL" 17 "PT" 19 "RU" 15 "SE" 7 "SI" 1 "SK" 6 "TR" 16 "UA"
		

		label values order countrylabel
	
		gen lower=b_dummy1834-(1.96*se_dummy1834)
		gen upper=b_dummy1834+(1.96*se_dummy1834)

		graph set window fontface "Arial Narrow"
	
		tw rspike lower upper order, vert || scatter  b_dummy1834 order, msymbol(o)  msize(small)  ///
		xlabel(1(1)32, valuelabel labsize(vsmall) angle(0)) ytitle("") ///
		ylabel(-0.7(0.1).7, labsize(small)) yscale(r(-0.7(0.1).7)) ///
		xtitle("Estimated effect of cohabitation with only young adults") ///
		legend(off) yline(0) xsc(reverse) xsize(6) ysize(4) title("Government") aspectratio(0.4) ///
		graphregion(margin(vsmall)) scheme(lean1) saving(${figures}/Figure_country_government.gph, replace)
		
		
		
		cd "${figures}"
		
		graph combine Figure_country_economy.gph Figure_country_government.gph , ///
		col(1) 
		
		graph export ${figures}/appendixO.pdf,   replace
